home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / sos3-2.lha / src / mta / mta_scp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-23  |  35.5 KB  |  1,199 lines

  1. #line 1 "/fzi/prost/stone/SOS3-2/src/mta/mta.c"
  2. /* --------------------------------------------------------------------------
  3.  * Copyright 1992 by Forschungszentrum Informatik (FZI)
  4.  *
  5.  * You can use and distribute this software under the terms of the licence
  6.  * you should have received along with this program.
  7.  * If not or if you want additional information, write to
  8.  * Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
  9.  * D-7500 Karlsruhe 1, Germany.
  10.  * --------------------------------------------------------------------------
  11.  */
  12. // **************************************************************************
  13. // Module mta                       03/06/89                 Juergen Uhl (ju)
  14. //
  15. // **************************************************************************
  16. // implements methods of all classes declared in schema "mta" 
  17. // **************************************************************************
  18.  
  19. #include "sys.h"
  20. #include "smg.h"
  21. #include "mta_err.h"
  22. #include "trc_mta.h"
  23.  
  24. #include "dir_use.h"
  25. #include "cci_use.h"
  26.  
  27. #include "mta_sos.h"
  28.  
  29. static sos_Schema_type get_object_type();
  30. static sos_Schema_type get_scalar_object_type();
  31.  
  32. // *************************************************************************
  33. sos_Schema_type _sos_Imports::lookup_type (sos_Typed_id &_tpid,sos_String name,
  34.                       sos_Bool   look_for_alias)
  35. // *************************************************************************
  36.  
  37. {  
  38.    T_PROC ("sos_Imports::lookup_type");
  39.    TT (mta_H, T_ENTER);
  40.  
  41.    sos_Schema_type result = sos_Schema_type::make (NO_OBJECT);
  42.    sos_Imports     imp    = sos_Imports::make(_tpid,this);
  43.    agg_iterate (imp, sos_Schema_module sm)
  44.    {  result = sm.get_type_table()[name];
  45.       if (result != NO_OBJECT)
  46.      if (NOT look_for_alias AND
  47.          NOT result.get_name().equal(name))
  48.         result = sos_Schema_type::make (NO_OBJECT);
  49.      else
  50.         break;
  51.    }
  52.    agg_iterate_end (imp, sm);
  53.  
  54.    TT (mta_H, T_LEAVE);
  55.  
  56.    return result;
  57. }
  58.  
  59. // *************************************************************************
  60. sos_Schema_module_Directory _sos_Schema_module::schema_dir ()
  61. // *************************************************************************
  62. {
  63.    T_PROC ("sos_Schema_module::schema_dir");
  64.    TT (mta_H, T_ENTER);
  65.  
  66.    sos_String name;
  67.    sos_Schema_module_Directory dir;
  68.    sos_Directory root_dir;
  69.  
  70.    name = smg_String ("sos_schemas").make_String (TEMP_CONTAINER);
  71.    ROOT_CONTAINER.open (READING, WAITING);
  72.    root_dir = sos_Object_Directory::root();
  73.    dir = sos_Schema_module_Directory::make (root_dir [name]);
  74.    ROOT_CONTAINER.close ();
  75.    if (dir == NO_OBJECT)
  76.    {  dir = sos_Schema_module_Directory::create (sos_Container::create(), name);
  77.       ROOT_CONTAINER.open (WRITING, WAITING);
  78.       root_dir.insert (name, dir);
  79.       ROOT_CONTAINER.close ();
  80.    }
  81.    name.destroy();
  82.  
  83.    TT (mta_H, T_LEAVE);
  84.  
  85.    return dir;
  86. }
  87.  
  88. // *************************************************************************
  89. sos_Schema_module _sos_Schema_module::lookup (sos_String name)
  90. // *************************************************************************
  91. {  T_PROC ("sos_Schema_module::lookup")
  92.    TT (mta_H, T_ENTER);
  93.  
  94.    sos_Schema_module sm;
  95.    sos_Schema_module_Directory sd = sos_Schema_module::schema_dir ();
  96.  
  97.    sd.container().open (READING, WAITING);
  98.    if (sd.is_key (name))
  99.       sm = sos_Schema_module::make (sd [name]);
  100.    else
  101.       sm = sos_Schema_module::make (NO_OBJECT);
  102.    sd.container().close ();
  103.  
  104.    TT (mta_H, T_LEAVE);
  105.  
  106.    return sm;
  107. }
  108.  
  109. // *************************************************************************
  110. sos_Schema_module _sos_Schema_module::retrieve (sos_Container ct)
  111. // *************************************************************************
  112. {  T_PROC ("sos_Schema_module::retrieve")
  113.    TT (mta_H, T_ENTER);
  114.  
  115.    sos_Schema_module sm = sos_Schema_module::make (ct.root_object());
  116.  
  117.    TT (mta_H, T_LEAVE);
  118.    return sm;
  119. }
  120.  
  121. // *************************************************************************
  122. sos_Schema_type _sos_Schema_module::lookup_type
  123.                      (sos_Typed_id &_tpid,sos_String name, sos_Bool look_for_alias)
  124. // *************************************************************************
  125.  
  126. // search for a type declaration with 'name' in the type table
  127. // of the schema module. If no declaration is found search for 'name'
  128. // in the type tables of the imported modules. If the search fails
  129. // return NO_OBJECT.
  130.  
  131. {  T_PROC ("sos_Schema_module::lookup_type")
  132.    TT (mta_H, T_ENTER);
  133.  
  134.    sos_Schema_type result;
  135.    sos_Type_table  tt = sos_Schema_module::make(_tpid,this).get_type_table();
  136.  
  137.    result = tt[name];
  138.    if (result == NO_OBJECT)
  139.       result = sos_Schema_module::make(_tpid,this).get_imports().lookup_type (name, look_for_alias);
  140.    else if (NOT look_for_alias AND
  141.         NOT result.get_name().equal(name))
  142.       result = sos_Schema_type::make (NO_OBJECT);
  143.  
  144.    TT (mta_H, T_LEAVE);
  145.  
  146.    return result;
  147. }
  148.  
  149. // *************************************************************************
  150. void _sos_Schema_module::open_imports (sos_Typed_id &_tpid)
  151. // *************************************************************************
  152. {
  153.    T_PROC ("sos_Schema_module::open_imports");
  154.    TT (mta_H, T_ENTER);
  155.  
  156.    sos_Imports imp = sos_Schema_module::make(_tpid,this).get_imports();
  157.    agg_iterate (imp, sos_Schema_module sm)
  158.    {  sm.container().open(READING, WAITING);
  159.    }
  160.    agg_iterate_end (imp, sm);
  161.  
  162.    TT (mta_H, T_LEAVE);
  163. }
  164.  
  165. // *************************************************************************
  166. void _sos_Schema_module::close_imports (sos_Typed_id &_tpid)
  167. // *************************************************************************
  168. {
  169.    T_PROC ("sos_Schema_module::close_imports");
  170.    TT (mta_H, T_ENTER);
  171.  
  172.    sos_Imports imp = sos_Schema_module::make(_tpid,this).get_imports();
  173.    agg_iterate (imp, sos_Schema_module sm)
  174.    {  sm.container().close();
  175.    }
  176.    agg_iterate_end (imp, sm);
  177.  
  178.    TT (mta_H, T_LEAVE);
  179. }
  180.  
  181. // *************************************************************************
  182. void _sos_Schema_module::install (sos_Typed_id &_tpid)
  183. // *************************************************************************
  184. {
  185.    T_PROC ("sos_Schema_module::install");
  186.    TT (mta_H, T_ENTER);
  187.  
  188.    sos_String str;
  189.    sos_Container ct;
  190.    sos_Schema_module_Directory sd = sos_Schema_module::schema_dir ();
  191.  
  192.    sd.container().open (WRITING, WAITING);
  193.    str = sos_Schema_module::make(_tpid,this).get_name ();
  194.    if (sd.is_key (str))
  195.    {  // not yet implemented:
  196.       // info that schemas must be recompiled
  197.       ct = sd[str].container();
  198.       sd.remove (str);
  199.       ct.open (WRITING, WAITING);
  200.       ct.destroy();
  201.       ct.close();
  202.    }
  203.  
  204.    sd.insert (str, sos_Schema_module::make(_tpid,this));
  205.    sd.container().close ();
  206.  
  207.    TT (mta_H, T_LEAVE);
  208. }
  209.  
  210. // *************************************************************************
  211. sos_Schema_type _sos_Type_name::make_base_type (sos_Typed_id &_tpid)
  212. // *************************************************************************
  213. {  
  214.    T_PROC ("sos_Type_name::make_base_type");
  215.    TT (mta_H, T_ENTER);
  216.  
  217.    sos_Schema_type result = sos_Type_name::make(_tpid,this).make_type();
  218.  
  219.    TT (mta_H, T_LEAVE);
  220.  
  221.    return result;
  222. }
  223.  
  224. // *************************************************************************
  225. sos_Expr_List _sos_Type_name::create_params (sos_Typed_id &_tpid)
  226. // *************************************************************************
  227. {  
  228.    T_PROC ("sos_Type_name::create_params");
  229.    TT (mta_H, T_ENTER);
  230.  
  231.    sos_Expr_List result = sos_Expr_List::make (NO_OBJECT);
  232.  
  233.    TT (mta_H, T_LEAVE);
  234.  
  235.    return result;
  236. }
  237.  
  238. // *************************************************************************
  239. sos_Schema_type _sos_Type_name::make_root_type (sos_Typed_id &_tpid)
  240. // *************************************************************************
  241. {  
  242.    T_PROC ("sos_Type_name::make_root_type");
  243.    TT (mta_H, T_ENTER);
  244.  
  245.    sos_Schema_type result = sos_Type_name::make(_tpid,this).make_base_type();
  246.    if (NOT sos_Type_name::make(_tpid,this).identical (result))
  247.       result = result.make_root_type();
  248.  
  249.    TT (mta_H, T_LEAVE);
  250.  
  251.    return result;
  252. }
  253.  
  254. // *************************************************************************
  255. sos_Schema_type _sos_Schema_type::make_type (sos_Typed_id &_tpid)
  256. // *************************************************************************
  257. {  
  258.    T_PROC ("sos_Schema_type::make_type");
  259.    TT (mta_H, T_ENTER);
  260.  
  261.    sos_Schema_type result = sos_Schema_type::make(_tpid,this);
  262.  
  263.    TT (mta_H, T_LEAVE);
  264.  
  265.    return result;
  266. }
  267.  
  268. // *************************************************************************
  269. sos_String _sos_Schema_type::make_type_name (sos_Typed_id &_tpid)
  270. // *************************************************************************
  271. {  
  272.    T_PROC ("sos_Schema_type::make_type_name");
  273.    TT (mta_H, T_ENTER);
  274.  
  275.    sos_String result = sos_Schema_type::make(_tpid,this).get_name();
  276.  
  277.    TT (mta_H, T_LEAVE);
  278.  
  279.    return result;
  280. }
  281.  
  282. // *************************************************************************
  283. sos_Bool _sos_Schema_type::is_derived_from (sos_Typed_id &_tpid,sos_Type tp)
  284. // *************************************************************************
  285. {
  286.    T_PROC ("sos_Schema_type::is_derived_from");
  287.    TT (mta_H, T_ENTER);
  288.  
  289.    sos_Bool result;
  290.  
  291.    sos_Type b1 = sos_Schema_type::make(_tpid,this).base ();
  292.    sos_Type b2 = tp.base ();
  293.  
  294. #ifdef ATT
  295.    if (b1.operator== (b2))
  296. #else
  297.    if (b1 == b2)
  298. #endif
  299.       result = TRUE;
  300.    else
  301.    {
  302. #ifdef ATT
  303.       if (sos_Schema_type::make(_tpid,this).operator!= (b1)  OR  tp.operator!= (b2))
  304. #else
  305.       if (sos_Schema_type::make(_tpid,this) != b1 OR tp != b2)
  306. #endif
  307.      result = b1.is_derived_from (b2);
  308.       else if (b1.has_type (sos_Extern_type_type) OR
  309.            b1.has_type (sos_Enum_type_type))
  310.      result = get_scalar_object_type().is_derived_from (b2);
  311.         // this handles the cases:
  312.         //  - b2 is no scalar type
  313.         //  - b2 is a scalar type different from b1
  314.         // 'b2 is a scalar type identical with b1' is handled above
  315.       else
  316.      result = (sos_Bool)(b1.equal (b2) OR
  317.                  b2.equal (get_object_type()));
  318.    }
  319.  
  320.    TT (mta_H, T_LEAVE; TB (result));
  321.  
  322.    return result;
  323. }
  324.  
  325. // *************************************************************************
  326. sos_Bool _sos_Schema_type::is_derived_from_some (sos_Typed_id &_tpid,sos_Type tp)
  327. // *************************************************************************
  328. {
  329.    T_PROC ("sos_Schema_type::is_derived_from_some");
  330.    TT (mta_H, T_ENTER);
  331.  
  332.    sos_Bool result;
  333.  
  334.    sos_Type b1 = sos_Schema_type::make(_tpid,this).base ();
  335.    sos_Type b2 = tp.base ();
  336.  
  337. #ifdef ATT
  338.    if (b1.operator== (b2))
  339. #else
  340.    if (b1 == b2)
  341. #endif
  342.       result = TRUE;
  343.    else
  344.    {
  345. #ifdef ATT
  346.       if (sos_Schema_type::make(_tpid,this).operator!= (b1)  OR  tp.operator!= (b2))
  347. #else
  348.       if (sos_Schema_type::make(_tpid,this) != b1 OR tp != b2)
  349. #endif
  350.      result = b1.is_derived_from_some (b2);
  351.       else if (b1.has_type (sos_Extern_type_type) OR
  352.            b1.has_type (sos_Enum_type_type))
  353.      result = get_scalar_object_type().is_derived_from_some (b2);
  354.         // this handles the cases:
  355.         //  - b2 is no scalar type
  356.         //  - b2 is a scalar type different from b1
  357.         // 'b2 is a scalar type identical with b1' is handled above
  358.       else
  359.      result = (sos_Bool)(b1.equal (b2) OR
  360.                  b2.equal (get_object_type()));
  361.    }
  362.  
  363.    TT (mta_H, T_LEAVE; TB (result));
  364.  
  365.    return result;
  366. }
  367.  
  368. // *************************************************************************
  369. sos_Type _sos_Schema_type::base (sos_Typed_id &_tpid)
  370. // *************************************************************************
  371. {  
  372.    T_PROC ("sos_Schema_type::base");
  373.    TT (mta_H, T_ENTER);
  374.  
  375.    sos_Type t = sos_Schema_type::make(_tpid,this).make_base_type();
  376.  
  377.    TT (mta_H, T_LEAVE);
  378.  
  379.    return t;
  380. }
  381.  
  382. // *************************************************************************
  383. sos_Bool _sos_Schema_type::is_scalar (sos_Typed_id &_tpid)
  384. // *************************************************************************
  385. {  T_PROC ("sos_Schema_type::is_scalar")
  386.    TT (mta_H, T_ENTER);
  387.  
  388.    sos_Type bt = sos_Schema_type::make(_tpid,this).base ();
  389.    sos_Bool result = (sos_Bool) (bt.has_type (sos_Extern_type_type) OR
  390.                  bt.has_type (sos_Enum_type_type));
  391.  
  392.    TT (mta_H, T_LEAVE; TB (result));
  393.    return result;
  394. }
  395.  
  396. // *************************************************************************
  397. sos_Bool _sos_Schema_type::total_equal (sos_Schema_type x,
  398.                        sos_Object      o,
  399.                        sos_Eq_kind       )
  400. // *************************************************************************
  401. {
  402.    T_PROC ("sos_Schema_type::total_equal");
  403.    TT (mta_H, T_ENTER);
  404.  
  405.    sos_Bool result;
  406.  
  407.    sos_Type y = sos_Type::make (o);
  408.    sos_Type b1 = x.base ();
  409.    sos_Type b2 = y.base ();
  410.  
  411. #ifdef ATT
  412.    if (x.operator!= (b1)  OR  y.operator!= (b2))
  413.       result = b1.equal (b2);
  414.    else
  415.       result = b1.operator==(b2);
  416. #else
  417.    if (x != b1 OR y != b2)
  418.       result = b1.equal (b2);
  419.    else
  420.       result = b1 == b2;
  421. #endif
  422.  
  423.    TT (mta_H, T_LEAVE; TB (result));
  424.  
  425.    return result;
  426. }
  427.  
  428. // *************************************************************************
  429. sos_Int _sos_Schema_type::total_hash_value (sos_Schema_type)
  430. // *************************************************************************
  431. {
  432.    T_PROC ("sos_Schema_type::total_hash_value");
  433.    TT (mta_H, T_ENTER);
  434.  
  435.    sos_Int result = 0;
  436.  
  437.    TT (mta_H, T_LEAVE; TB (result));
  438.  
  439.    return result;
  440. }
  441.  
  442. // *************************************************************************
  443. sos_Schema_type _sos_Unidentified_type::make_type (sos_Typed_id &_tpid)
  444. // *************************************************************************
  445. {  
  446.    T_PROC ("sos_Unidentified_type::make_type");
  447.    TT (mta_H, T_ENTER);
  448.  
  449.    sos_Schema_type result = sos_Schema_type::make (NO_OBJECT);
  450.  
  451.    TT (mta_H, T_LEAVE);
  452.  
  453.    return result;
  454. }
  455.  
  456. // *************************************************************************
  457. sos_String _sos_Unidentified_type::make_type_name (sos_Typed_id &_tpid)
  458. // *************************************************************************
  459. {  
  460.    T_PROC ("sos_Unidentified_type::make_type_name");
  461.    TT (mta_H, T_ENTER);
  462.  
  463.    sos_String result = sos_Unidentified_type::make(_tpid,this).get_name();
  464.  
  465.    TT (mta_H, T_LEAVE);
  466.  
  467.    return result;
  468. }
  469.  
  470. // *************************************************************************
  471. sos_Expr_List _sos_Type_with_params::create_params (sos_Typed_id &_tpid)
  472. // *************************************************************************
  473. {  
  474.    T_PROC ("sos_Type_with_params::create_params");
  475.    TT (mta_H, T_ENTER);
  476.  
  477.    sos_Expr_List result = sos_Type_with_params::make(_tpid,this).get_params();
  478.  
  479.    TT (mta_H, T_LEAVE);
  480.  
  481.    return result;
  482. }
  483.  
  484. // *************************************************************************
  485. sos_Schema_type _sos_Type_with_params::make_type (sos_Typed_id &_tpid)
  486. // *************************************************************************
  487. {  
  488.    T_PROC ("sos_Type_with_params::make_type");
  489.    TT (mta_H, T_ENTER);
  490.  
  491.    sos_Schema_type result = sos_Type_with_params::make(_tpid,this).get_type_name().make_type();
  492.  
  493.    TT (mta_H, T_LEAVE);
  494.  
  495.    return result;
  496. }
  497.  
  498. // *************************************************************************
  499. sos_String _sos_Type_with_params::make_type_name (sos_Typed_id &_tpid)
  500. // *************************************************************************
  501. {  
  502.    T_PROC ("sos_Type_with_params::make_type_name");
  503.    TT (mta_H, T_ENTER);
  504.  
  505.    sos_String result = sos_Type_with_params::make(_tpid,this).get_type_name().make_type_name();
  506.  
  507.    TT (mta_H, T_LEAVE);
  508.  
  509.    return result;
  510. }
  511.  
  512. // *************************************************************************
  513. sos_Schema_type _sos_Generic_instantiation::make_type (sos_Typed_id &_tpid)
  514. // *************************************************************************
  515. {  
  516.    T_PROC ("sos_Generic_instantiation::make_type");
  517.    TT (mta_H, T_ENTER);
  518.  
  519.    sos_Schema_type result = sos_Generic_instantiation::make(_tpid,this).get_instantiation();
  520.  
  521.    TT (mta_H, T_LEAVE);
  522.  
  523.    return result;
  524. }
  525.  
  526. // *************************************************************************
  527. sos_String _sos_Generic_instantiation::make_type_name (sos_Typed_id &_tpid)
  528. // *************************************************************************
  529. {  
  530.    T_PROC ("sos_Generic_instantiation::make_type_name");
  531.    TT (mta_H, T_ENTER);
  532.  
  533.    sos_String result = sos_Generic_instantiation::make(_tpid,this).get_instantiation().make_type_name();
  534.  
  535.    TT (mta_H, T_LEAVE);
  536.  
  537.    return result;
  538. }
  539.  
  540. // *************************************************************************
  541. sos_Bool _sos_Generic_instantiation::is_universal (sos_Typed_id &_tpid)
  542. // *************************************************************************
  543. {  
  544.    T_PROC ("sos_Generic_instantiation::is_universal");
  545.    TT (mta_H, T_ENTER);
  546.  
  547.    sos_Class_type gen_t = sos_Generic_instantiation::make(_tpid,this).get_gen();
  548.  
  549.    sos_Type_name_List tnl = sos_Generic_instantiation::make(_tpid,this).get_gen_params();
  550.    sos_Gen_param_List gpl = sos_Class_type::make (gen_t).get_gen_params();
  551.  
  552.    sos_Bool is_universal = TRUE;
  553.    sos_Cursor c1 = tnl.open_cursor ();
  554.    sos_Cursor c2 = gpl.open_cursor ();
  555.    for (sos_Bool valid1 = tnl.is_valid (c1),
  556.          valid2 = gpl.is_valid (c2);
  557.         valid1 AND valid2 AND is_universal;
  558.         valid1 = tnl.to_succ (c1), valid2 = gpl.to_succ (c2))
  559.    {  is_universal =
  560.       tnl.get(c1).make_base_type ().equal (gpl.get(c2).make_base_type());
  561.    }
  562.    tnl.close_cursor (c1);
  563.    gpl.close_cursor (c2);
  564.  
  565.  
  566.    TT (mta_H, T_LEAVE);
  567.  
  568.    return is_universal;
  569. }
  570.  
  571. // *************************************************************************
  572. sos_Schema_type _sos_Gen_param::make_type (sos_Typed_id &_tpid)
  573. // *************************************************************************
  574. {  
  575.    T_PROC ("sos_Gen_param::make_type");
  576.    TT (mta_H, T_ENTER);
  577.  
  578.    sos_Type_name sc = sos_Gen_param::make(_tpid,this).get_super_class();
  579.    sos_Schema_type result;
  580.    if (sc == NO_OBJECT)
  581.       result = (get_object_type());
  582.    else
  583.       result = sc.make_type ();
  584.  
  585.    TT (mta_H, T_LEAVE);
  586.  
  587.    return result;
  588. }
  589.  
  590. // *************************************************************************
  591. sos_String _sos_Gen_param::make_type_name (sos_Typed_id &_tpid)
  592. // *************************************************************************
  593. {  
  594.    T_PROC ("sos_Gen_param::make_type_name");
  595.    TT (mta_H, T_ENTER);
  596.  
  597.    sos_Type_name sc = sos_Gen_param::make(_tpid,this).get_super_class();
  598.    sos_String result;
  599.    if (sc == NO_OBJECT)
  600.       result = (get_object_type().make_type_name());
  601.    else
  602.       result = sc.make_type_name();
  603.  
  604.    TT (mta_H, T_LEAVE);
  605.  
  606.    return result;
  607. }
  608.  
  609. // *************************************************************************
  610. sos_Bool _sos_Method::overloads (sos_Typed_id &_tpid,sos_Method m)
  611. // *************************************************************************
  612. // precondition: self.name == m.name
  613. {  
  614.    T_PROC ("sos_Method::overloads");
  615.    TT (mta_H, T_ENTER);
  616.  
  617.    sos_Bool result = (sos_Bool)
  618.             (sos_Method::make(_tpid,this).get_is_static() == m.get_is_static() AND
  619.              sos_Method::make(_tpid,this).get_params().card() != m.get_params().card());
  620.  
  621.    TT (mta_H, T_LEAVE; TB(result));
  622.    return result;
  623. }
  624.  
  625. // *************************************************************************
  626. sos_Bool _sos_Method::redefines (sos_Typed_id &_tpid,sos_Method m)
  627. // *************************************************************************
  628. {  
  629. // precondition: self.get_name() == m.get_name()
  630.  
  631.    T_PROC ("sos_Method::redefines");
  632.    TT (mta_H, T_ENTER);
  633.  
  634.    sos_Bool result;
  635.  
  636.    if (sos_Method::make(_tpid,this).get_is_static() != m.get_is_static())
  637.       result = FALSE;
  638.    else
  639.    {  sos_Type ts = sos_Method::make(_tpid,this).get_result_type().make_base_type();
  640.       sos_Type tm =    m.get_result_type().make_base_type();
  641.       
  642.       if (ts.equal (tm))
  643.       {  result             = TRUE;
  644.          sos_Param_List pls = sos_Method::make(_tpid,this).get_params();
  645.          sos_Param_List plm =    m.get_params();
  646.  
  647.          sos_Int comp = 0;
  648.          agg_iterate_double (pls, sos_Param ps, plm, sos_Param pm, comp)
  649.          {  ts = ps.get_type_name().make_base_type();
  650.         tm = pm.get_type_name().make_base_type();
  651.         result = ts.equal (tm);
  652.         if (NOT result) break;
  653.          }
  654.          agg_iterate_double_end (pls, ps, plm, pm, comp);
  655.          result = (sos_Bool)(result AND comp == 0);
  656.       }
  657.       else
  658.          result = FALSE;
  659.    }
  660.  
  661.    TT (mta_H, T_LEAVE; TB(result));
  662.    return result;
  663. }
  664.  
  665. // *************************************************************************
  666. sos_Object _sos_Method::execute (sos_Typed_id &_tpid,sos_Object o, sos_Object_Array p)
  667. // *************************************************************************
  668. {  
  669.    T_PROC ("sos_Method::is_execute");
  670.    TT (mta_H, T_ENTER);
  671.  
  672.    sos_Object result;
  673.    sos_Method_impl_List impls = sos_Method::make(_tpid,this).get_impls();
  674.    sos_Bool found = FALSE;
  675.    if (impls != NO_OBJECT)
  676.    {  agg_iterate (impls, sos_Method_impl impl)
  677.       {  if (impl.isa (cci_Method_impl_type))
  678.      {  result = cci_Method_impl::make (impl).execute (o, p);
  679.         found = TRUE;
  680.         break;
  681.      }
  682.       }
  683.       agg_iterate_end (impls, impl);
  684.    }
  685.    if (NOT found)
  686.       err_raise (err_SYS, err_MTA_METHOD_NOT_EXECUTABLE,
  687.               sos_Method::make(_tpid,this).get_name().make_Cstring());
  688.  
  689.    TT (mta_H, T_LEAVE);
  690.    return result;
  691. }
  692.  
  693. // *************************************************************************
  694. sos_Method _sos_Method_table::lookup (sos_Typed_id &_tpid,sos_Method m)
  695. // *************************************************************************
  696. {
  697.    T_PROC ("sos_Method_table::lookup");
  698.    TT (mta_H, T_ENTER);
  699.  
  700.    sos_Method result = sos_Method::make (NO_OBJECT);
  701.    sos_String m_name = m.get_name();
  702.  
  703.    if (sos_Method_table::make(_tpid,this).is_key (m_name))
  704.    {  sos_Method_List ml = sos_Method_table::make(_tpid,this)[m_name];
  705.  
  706.       agg_iterate (ml, sos_Method m1)
  707.       {  if (NOT m.overloads (m1))
  708.      {  result = m1;
  709.         break;
  710.      }
  711.       }
  712.       agg_iterate_end (ml, m1);
  713.    }
  714.  
  715.    TT (mta_H, T_LEAVE);
  716.    return result;
  717. }
  718.  
  719. // *************************************************************************
  720. sos_Method _sos_Method_table::lookup_or_add (sos_Typed_id &_tpid,sos_Method m)
  721. // *************************************************************************
  722. {
  723.    T_PROC ("sos_Method_table::lookup_or_add");
  724.    TT (mta_H, T_ENTER);
  725.  
  726.    sos_Method result;
  727.    sos_String m_name = m.get_name();
  728.    sos_Method_List ml;
  729.    sos_Bool found = FALSE;
  730.  
  731.    if (sos_Method_table::make(_tpid,this).is_key (m_name))
  732.    {  ml = sos_Method_table::make(_tpid,this)[m_name];
  733.  
  734.       agg_iterate (ml, sos_Method m1)
  735.          if (NOT m.overloads (m1))
  736.      {  found = TRUE;
  737.         result = m1;
  738.         break;
  739.      }
  740.       agg_iterate_end (ml, m1);
  741.    }
  742.    else
  743.    {  ml = sos_Method_List::create (sos_Method_table::make(_tpid,this).container(), FALSE);
  744.       sos_Method_table::make(_tpid,this).insert (m_name, ml);
  745.    }
  746.  
  747.    if (NOT found)
  748.    {  ml.append (m);
  749.       result = m;
  750.    }
  751.  
  752.    TT (mta_H, T_LEAVE;TB(found));
  753.    return result;
  754. }
  755.  
  756. // *************************************************************************
  757. sos_Method _sos_Method_table::replace_or_add (sos_Typed_id &_tpid,sos_Method m)
  758. // *************************************************************************
  759. {
  760.    T_PROC ("sos_Method_table::replace_or_add");
  761.    TT (mta_H, T_ENTER);
  762.  
  763.    sos_Method      result;
  764.    sos_String      m_name = m.get_name();
  765.    sos_Method_List ml;
  766.    sos_Bool        found = FALSE;
  767.  
  768.    if (sos_Method_table::make(_tpid,this).is_key (m_name))
  769.    {  ml = sos_Method_table::make(_tpid,this)[m_name];
  770.  
  771.       sos_Cursor c = ml.open_cursor();
  772.       for (sos_Bool valid = ml.is_valid (c); valid; valid = ml.to_succ (c))
  773.       {  sos_Method m1 = ml.get(c);
  774.          if (NOT m.overloads (m1))
  775.      {  ml.set (c, m);
  776.         found = TRUE;
  777.         result = m1;
  778.         break;
  779.      }
  780.       }
  781.       ml.close_cursor (c);
  782.    }
  783.    else
  784.    {  ml = sos_Method_List::create (sos_Method_table::make(_tpid,this).container(), FALSE);
  785.       sos_Method_table::make(_tpid,this).insert (m_name, ml);
  786.    }
  787.  
  788.    if (NOT found)
  789.    {  ml.append (m);
  790.       result = m;
  791.    }
  792.  
  793.    TT (mta_H, T_LEAVE);
  794.    return result;
  795. }
  796.  
  797. // *************************************************************************
  798. sos_Comp_method _sos_Method_table::lookup_comp (sos_Typed_id &_tpid,sos_String name,
  799.                            sos_Bool   is_set)
  800. // *************************************************************************
  801. {
  802.    T_PROC ("sos_Method_table::lookup_comp");
  803.    TT (mta_H, T_ENTER);
  804.  
  805.    sos_String mn = sos_String::create(TEMP_CONTAINER);
  806.    if (is_set)
  807.       mn.assign_Cstring ("set_");
  808.    else
  809.       mn.assign_Cstring ("get_");
  810.    mn += name;
  811.  
  812.    sos_Comp_method result = sos_Comp_method::make (NO_OBJECT);
  813.  
  814.    if (sos_Method_table::make(_tpid,this).is_key (mn))
  815.    {  sos_Method_List ml = sos_Method_table::make(_tpid,this)[mn];
  816.  
  817.       agg_iterate (ml, sos_Method m)
  818.          if (m.has_type (sos_Comp_method_type))
  819.      {  result = sos_Comp_method::make (m);
  820.         break;
  821.      }
  822.       agg_iterate_end (ml, m);
  823.    }
  824.  
  825.    mn.destroy();
  826.  
  827.    TT (mta_H, T_LEAVE);
  828.    return result;
  829. }
  830.  
  831. // *************************************************************************
  832. sos_Bool _sos_Union_type::local_equal (sos_Union_type,sos_Object,sos_Eq_kind)
  833. // *************************************************************************
  834. {  
  835.    T_PROC ("sos_Union_type::local_equal");
  836.    TT (mta_H, T_ENTER);
  837.  
  838.    sos_Bool result = TRUE;
  839.  
  840.    TT (mta_H, T_LEAVE);
  841.    return result;
  842. }
  843.  
  844. // *************************************************************************
  845. sos_Int _sos_Union_type::local_hash_value (sos_Union_type)
  846. // *************************************************************************
  847. {  
  848.    T_PROC ("sos_Union_type::local_hash_value");
  849.    TT (mta_H, T_ENTER);
  850.  
  851.    sos_Int result = 0;
  852.  
  853.    TT (mta_H, T_LEAVE);
  854.    return result;
  855. }
  856.  
  857. // *************************************************************************
  858. sos_Schema_type _sos_Typedef_type::make_base_type (sos_Typed_id &_tpid)
  859. // *************************************************************************
  860. {  
  861.    T_PROC ("sos_Typedef_type::make_base_type");
  862.    TT (mta_H, T_ENTER);
  863.  
  864.    sos_Schema_type t = sos_Typedef_type::make(_tpid,this).get_type_name().make_base_type();
  865.  
  866.    TT (mta_H, T_LEAVE);
  867.    return t;
  868. }
  869.  
  870. // *************************************************************************
  871. sos_Bool _sos_Typedef_type::local_equal (sos_Typedef_type,sos_Object,sos_Eq_kind)
  872. // *************************************************************************
  873. {  
  874.    T_PROC ("sos_Typedef_type::local_equal");
  875.    TT (mta_H, T_ENTER);
  876.  
  877.    sos_Bool result = TRUE;
  878.  
  879.    TT (mta_H, T_LEAVE);
  880.    return result;
  881. }
  882.  
  883. // *************************************************************************
  884. sos_Int _sos_Typedef_type::local_hash_value (sos_Typedef_type)
  885. // *************************************************************************
  886. {  
  887.    T_PROC ("sos_Typedef_type::local_hash_value");
  888.    TT (mta_H, T_ENTER);
  889.  
  890.    sos_Int result = 0;
  891.  
  892.    TT (mta_H, T_LEAVE);
  893.    return result;
  894. }
  895.  
  896. // *************************************************************************
  897. sos_Scalar_object _sos_Enum_type::make_object (sos_Typed_id &_tpid,sos_String literal)
  898. // *************************************************************************
  899. {  T_PROC ("sos_Enum_type::make_object");
  900.    TT (mta_H, T_ENTER);
  901.  
  902.    sos_String_List sl    = sos_Enum_type::make(_tpid,this).get_literals();
  903.    sos_Int         idx   = 0;
  904.    sos_Bool        found = FALSE;
  905.  
  906.    agg_iterate (sl, sos_String lit)
  907.       if (lit.equal (literal))
  908.       {  found = TRUE;
  909.          break;
  910.       }
  911.       ++ idx;
  912.    agg_iterate_end (sl, lit);
  913.  
  914.    sos_Scalar_object result = found ? sos_enum_from_sos_Int (idx, sos_Enum_type::make(_tpid,this))
  915.                     : sos_Scalar_object::make (NO_OBJECT);
  916.    TT (mta_H, T_LEAVE);
  917.    return result;
  918. }
  919.  
  920. // *************************************************************************
  921. sos_String _sos_Enum_type::make_string (sos_Typed_id &_tpid,sos_Scalar_object enum_obj)
  922. // *************************************************************************
  923. {  T_PROC ("sos_Enum_type::make_string");
  924.    TT (mta_H, T_ENTER);
  925.  
  926.    sos_Int    lidx          = sos_Int_from_enum (enum_obj, sos_Enum_type::make(_tpid,this)) + 1;
  927.    sos_String_List literals = sos_Enum_type::make(_tpid,this).get_literals();
  928.  
  929.    err_assert (1 <= lidx  AND  lidx <= literals.card(),
  930.                "sos_Enum_type::make_string : enum out of range");
  931.  
  932.    sos_String result = sos_String::clone (literals.get_nth (lidx),
  933.                                           TEMP_CONTAINER);
  934.    TT (mta_H, T_LEAVE);
  935.    return result;
  936. }
  937.  
  938. // *************************************************************************
  939. sos_Bool _sos_Enum_type::local_equal (sos_Enum_type,sos_Object,sos_Eq_kind)
  940. // *************************************************************************
  941. {  T_PROC ("sos_Enum_type::local_equal");
  942.    TT (mta_H, T_ENTER);
  943.  
  944.    sos_Bool result = TRUE;
  945.  
  946.    TT (mta_H, T_LEAVE);
  947.    return result;
  948. }
  949.  
  950. // *************************************************************************
  951. sos_Int _sos_Enum_type::local_hash_value (sos_Enum_type)
  952. // *************************************************************************
  953. {  
  954.    T_PROC ("sos_Enum_type::local_hash_value");
  955.    TT (mta_H, T_ENTER);
  956.  
  957.    sos_Int result = 0;
  958.  
  959.    TT (mta_H, T_LEAVE);
  960.    return result;
  961. }
  962.  
  963. // *************************************************************************
  964. sos_Schema_type _sos_Forward_class_type::make_base_type (sos_Typed_id &_tpid)
  965. // *************************************************************************
  966. {  
  967.    T_PROC ("sos_Forward_class_type::make_base_type");
  968.    TT (mta_H, T_ENTER);
  969.  
  970.    sos_Schema_type t = sos_Forward_class_type::make(_tpid,this).get_complete();
  971.    if (t == NO_OBJECT) t = sos_Forward_class_type::make(_tpid,this);
  972.  
  973.    TT (mta_H, T_LEAVE);
  974.    return t;
  975. }
  976.  
  977. // *************************************************************************
  978. sos_Bool _sos_Forward_class_type::local_equal (sos_Forward_class_type,sos_Object,sos_Eq_kind)
  979. // *************************************************************************
  980. {  
  981.    T_PROC ("sos_Forward_class_type::local_equal");
  982.    TT (mta_H, T_ENTER);
  983.  
  984.    sos_Bool result = TRUE;
  985.  
  986.    TT (mta_H, T_LEAVE);
  987.    return result;
  988. }
  989.  
  990. // *************************************************************************
  991. sos_Int _sos_Forward_class_type::local_hash_value (sos_Forward_class_type)
  992. // *************************************************************************
  993. {  
  994.    T_PROC ("sos_Forward_class_type::local_hash_value");
  995.    TT (mta_H, T_ENTER);
  996.  
  997.    sos_Int result = 0;
  998.  
  999.    TT (mta_H, T_LEAVE);
  1000.    return result;
  1001. }
  1002.  
  1003. // *************************************************************************
  1004. sos_Class_type _sos_Class_type::root_class (sos_Typed_id &_tpid)
  1005. // *************************************************************************
  1006. {
  1007.    T_PROC ("sos_Class_type::root_class");
  1008.    TT (mta_H, T_ENTER);
  1009.  
  1010.    sos_Class_type ct;
  1011.  
  1012.    sos_Generic_instantiation gi = sos_Class_type::make(_tpid,this).get_generated_from();
  1013.    if (gi != NO_OBJECT)
  1014.       ct = gi.get_gen();
  1015.    else
  1016.       ct = sos_Class_type::make(_tpid,this);
  1017.  
  1018.    TT (mta_H, T_LEAVE);
  1019.    return ct;
  1020. }
  1021.  
  1022. // *************************************************************************
  1023. sos_Bool _sos_Class_type::is_derived_from (sos_Typed_id &_tpid,sos_Type tp)
  1024. // *************************************************************************
  1025. {
  1026.    T_PROC ("sos_Class_type::is_derived_from");
  1027.    TT (mta_H, T_ENTER);
  1028.  
  1029.    sos_Bool result = FALSE;
  1030.  
  1031.    if (sos_Class_type::make(_tpid,this).equal (tp) OR tp.equal (get_object_type()))
  1032.       result = TRUE;
  1033.    else
  1034.    {  sos_Super_class_List scl = sos_Class_type::make(_tpid,this).get_super_closure();
  1035.  
  1036.       agg_iterate (scl, sos_Super_class sc)
  1037.          if (sc.get_super_class().equal (tp))
  1038.      {  result = TRUE;
  1039.         break;
  1040.      }
  1041.       agg_iterate_end (scl, sc);
  1042.    }
  1043.  
  1044.    TT (mta_H, T_LEAVE; TB (result));
  1045.    return result;
  1046. }
  1047.  
  1048. // *************************************************************************
  1049. sos_Bool _sos_Class_type::is_derived_from_some (sos_Typed_id &_tpid,sos_Type tp)
  1050. // *************************************************************************
  1051. {
  1052.    T_PROC ("sos_Class_type::is_derived_from_some");
  1053.    TT (mta_H, T_ENTER);
  1054.  
  1055.    sos_Bool result = FALSE;
  1056.  
  1057.    if (sos_Class_type::make(_tpid,this).equal (tp) OR tp.equal (get_object_type()))
  1058.       result = TRUE;
  1059.    else
  1060.    {  sos_Super_class_List scl = sos_Class_type::make(_tpid,this).get_super_closure();
  1061.  
  1062.       agg_iterate (scl, sos_Super_class sc)
  1063.          if (sc.get_super_class().root_class().equal (tp))
  1064.      {  result = TRUE;
  1065.         break;
  1066.      }
  1067.       agg_iterate_end (scl, sc);
  1068.    }
  1069.  
  1070.    TT (mta_H, T_LEAVE; TB (result));
  1071.    return result;
  1072. }
  1073.  
  1074. // *************************************************************************
  1075. sos_Type _sos_Class_type::root (sos_Typed_id &_tpid)
  1076. // *************************************************************************
  1077. {
  1078.    T_PROC ("sos_Class_type::root");
  1079.    TT (mta_M, T_ENTER);
  1080.  
  1081.    sos_Type t = sos_Class_type::make(_tpid,this).root_class();
  1082.  
  1083.    TT (mta_M, T_LEAVE);
  1084.    return t;
  1085. }
  1086.  
  1087. // *************************************************************************
  1088. sos_Schema_type _sos_Class_type::make_root_type (sos_Typed_id &_tpid)
  1089. // *************************************************************************
  1090. {
  1091.    T_PROC ("sos_Class_type::make_root_type");
  1092.    TT (mta_H, T_ENTER);
  1093.  
  1094.    sos_Schema_type t = sos_Class_type::make(_tpid,this).root_class();
  1095.  
  1096.    TT (mta_H, T_LEAVE);
  1097.    return t;
  1098. }
  1099.  
  1100. // *************************************************************************
  1101. sos_String _sos_Class_type::make_type_name (sos_Typed_id &_tpid)
  1102. // *************************************************************************
  1103. {  
  1104.    T_PROC ("sos_Class_type::make_type_name");
  1105.    TT (mta_H, T_ENTER);
  1106.  
  1107.    sos_String result = sos_Class_type::make(_tpid,this).get_root_name();
  1108.  
  1109.    if (result == NO_OBJECT)
  1110.       result = sos_Class_type::make(_tpid,this).get_name();
  1111.  
  1112.    TT (mta_H, T_LEAVE);
  1113.    return result;
  1114. }
  1115.  
  1116. static sos_Schema_type *the_object_type;
  1117.  
  1118. // *************************************************************************
  1119. static sos_Schema_type get_object_type()
  1120. // *************************************************************************
  1121. {
  1122.    T_PROC ("get_object_type");
  1123.    TT (mta_H, T_ENTER);
  1124.  
  1125.    sos_Schema_type result;
  1126.    if (the_object_type)
  1127.       result = *the_object_type;
  1128.    else
  1129.    {
  1130. #ifdef BOOT
  1131.       sos_Schema_module knl =
  1132.      sos_Schema_module::lookup (smg_String ("knl").make_String (TEMP_CONTAINER));
  1133.       result = knl.lookup_type (smg_String ("sos_Object").make_String (TEMP_CONTAINER));
  1134. #else
  1135.       result = sos_Schema_type::make (sos_Object_type);
  1136. #endif
  1137.       the_object_type  = new sos_Schema_type;
  1138.       *the_object_type = result;
  1139.    }
  1140.  
  1141.    TT (mta_H, T_LEAVE);
  1142.    return result;
  1143. }
  1144.  
  1145. static sos_Schema_type *the_scalar_object_type;
  1146.  
  1147. // *************************************************************************
  1148. static sos_Schema_type get_scalar_object_type()
  1149. // *************************************************************************
  1150. {
  1151.    T_PROC ("get_scalar_object_type");
  1152.    TT (mta_H, T_ENTER);
  1153.  
  1154.    sos_Schema_type result;
  1155.    if (the_scalar_object_type)
  1156.       result = *the_scalar_object_type;
  1157.    else
  1158.    {
  1159. #ifdef BOOT
  1160.       sos_Schema_module knl =
  1161.      sos_Schema_module::lookup (smg_String ("knl").make_String (TEMP_CONTAINER));
  1162.       result = knl.lookup_type (smg_String ("sos_Scalar_object").make_String (TEMP_CONTAINER));
  1163. #else
  1164.       result = sos_Schema_type::make (sos_Scalar_object_type);
  1165. #endif
  1166.       the_scalar_object_type  = new sos_Schema_type;
  1167.       *the_scalar_object_type = result;
  1168.    }
  1169.  
  1170.    TT (mta_H, T_LEAVE);
  1171.    return result;
  1172. }
  1173.  
  1174. // *************************************************************************
  1175. sos_Bool _sos_Class_type::local_equal (sos_Class_type,sos_Object,sos_Eq_kind)
  1176. // *************************************************************************
  1177. {  
  1178.    T_PROC ("sos_Class_type::local_equal");
  1179.    TT (mta_M, T_ENTER);
  1180.  
  1181.    sos_Bool result = TRUE;
  1182.  
  1183.    TT (mta_M, T_LEAVE);
  1184.    return result;
  1185. }
  1186.  
  1187. // *************************************************************************
  1188. sos_Int _sos_Class_type::local_hash_value (sos_Class_type)
  1189. // *************************************************************************
  1190. {  
  1191.    T_PROC ("sos_Class_type::local_hash_value");
  1192.    TT (mta_M, T_ENTER);
  1193.  
  1194.    sos_Int result = 0;
  1195.  
  1196.    TT (mta_M, T_LEAVE);
  1197.    return result;
  1198. }
  1199.